'use strict';
module.exports = app => {
  const { router, controller, config } = app;
  // 获取JWT中间件
  const jwt = app.middleware.jwt(config.jwt);
  /**
   * 上传文件
   */
  router.post('/api/upload/file', controller.uploadcos.file);
  // banner
  router.get('/api/banner/list', controller.banner.allList);
  router.resources('banner', '/api/banner', controller.banner);
  // 资讯收藏
  router.get('/api/collection/product', controller.collection.collectionProduct);
  router.resources('Collection', '/api/collection', controller.collection);
  // 产品分类
  router.get('/api/productCategory/list', controller.productCategory.allList);
  router.resources('productCategory', '/api/productCategory', controller.productCategory);
  // 产品
  router.get('/api/product/list', controller.product.allList);
  router.resources('product', '/api/product', controller.product);
  // 文件
  router.resources('file', '/api/file', controller.file);
  /**
   * 购物车
   */
  router.get('/api/cart/list', controller.cart.allList);
  router.post('/api/cart/batchDelete', controller.cart.batchDelete);
  router.post('/api/cart/statusAll', controller.cart.updateCartStatusAll);
  router.resources('cart', '/api/cart', controller.cart);
  /**
   * 用户
   */
  router.post('/api/user/wx/login', controller.user.wxLogin);
  // 用户
  router.get('/api/user/list', controller.user.allList);
  router.resources('user', '/api/user', controller.user);
  router.resources('address', '/api/address', controller.address);

  /**
   * 订单
   */
  // 获取订单详情
  router.get('/api/order/list', controller.order.allList);
  router.get('/api/order/detail', controller.order.detail);
  // 取消订单
  router.post('/api/order/cancel', controller.order.cancel);
  // 申请退款
  router.post('/api/order/refund', controller.order.refund);
  router.post('/api/order/refund/confirm', controller.order.refundConfirm);
  // 删除订单
  router.post('/api/order/delete', controller.order.delete);
  router.resources('order', '/api/order', controller.order);
  /**
   * 评论
   */
  router.resources('comment', '/api/comment', controller.comment);
  /**
   * 支付
   */
  // 创建支付订单
  router.post('/api/payment/wx', controller.payment.wxPay.createPayment);
  router.post('/api/wxPay/paymentWxNotify', controller.payment.wxPay.paymentWxNotify);
  router.post('/api/wxPay/refundWxNotify', controller.payment.wxPay.refundWxNotify);
  /**
   * 反馈管理
   */
  router.resources('feedback', '/api/feedback', controller.feedback);
};
